package com.ldzy.tinyaccount;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Timer;
import java.util.TimerTask;

public class LoginActivity extends AppCompatActivity {
    EditText ediPersonName,ediPersonPassword;
    TextView texPersonName,texPersonPassword,textviewNotPassword,textviewRegister;
    Button butLogin;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);


        Intent intent=getIntent();
        String str= intent.getStringExtra("login");
        ediPersonName.setText(str);
        initView();

    }

    protected  void  initView(){
         ediPersonName=findViewById(R.id.EditTextName);
         ediPersonPassword=findViewById(R.id.EditTextPassword);
         texPersonName=findViewById(R.id.TextviewName);
         texPersonPassword=findViewById(R.id.TextviewPassword);
         butLogin=findViewById(R.id.But_login);
         textviewNotPassword=findViewById(R.id.TextviewNotPassword);
         textviewRegister=findViewById(R.id.TextviewRegister);
         butLogin.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {
                 String name=ediPersonName.getText().toString().trim();
                 String password=ediPersonPassword.getText().toString().trim();
                 if(name.length()==0){
                     Toast.makeText(LoginActivity.this,"用户昵称不能为空",Toast.LENGTH_LONG).show();}
                  else if (password.length()==0)
                         Toast.makeText(LoginActivity.this,"密码不能为空",Toast.LENGTH_LONG).show();
                  else if (name.equals("123")&&password.equals("123"))
                     Toast.makeText(LoginActivity.this,"记账主页面未开放,敬请期待!",Toast.LENGTH_LONG).show();
                  else
                     Toast.makeText(LoginActivity.this,"账号或密码错误,请重新输入!",Toast.LENGTH_LONG).show();
             }
         });
         texPersonName.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {

             }
         });
         textviewNotPassword.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View view) {

             }
         });
    }

}